/**
 * 
 */
package com.furschina.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import cn.wooshai.core.model.WooshaiGeneratedModel;

/**
 * @author iday
 * 
 */
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "cache.weekly")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Navigation extends WooshaiGeneratedModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7120828689309452372L;
	private String name;
	private String url;
	private String color;
	private boolean bold = false;
	private boolean enable = true;
	private int sort = 0;
	@ManyToOne(fetch = FetchType.LAZY)
	@Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "cache.weekly")
	private Navigation parent;
	@OneToMany(fetch = FetchType.EAGER, orphanRemoval = true, mappedBy = "parent")
	@OrderBy("sort")
	@Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "cache.weekly")
	private List<Navigation> children;

	/**
	 * 
	 */
	public Navigation() {
	}

	/**
	 * @param name
	 */
	public Navigation(String name) {
		this.name = name;
	}

	/**
	 * @param name
	 * @param sort
	 * @param parent
	 */
	public Navigation(String name, String url, Navigation parent) {
		this.name = name;
		this.url = url;
		this.parent = parent;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url
	 *            the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the color
	 */
	public String getColor() {
		return color;
	}

	/**
	 * @param color
	 *            the color to set
	 */
	public void setColor(String color) {
		this.color = color;
	}

	/**
	 * @return the bold
	 */
	public boolean isBold() {
		return bold;
	}

	/**
	 * @param bold
	 *            the bold to set
	 */
	public void setBold(boolean bold) {
		this.bold = bold;
	}

	/**
	 * @return the enable
	 */
	public boolean isEnable() {
		return enable;
	}

	/**
	 * @param enable
	 *            the enable to set
	 */
	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	/**
	 * @return the sort
	 */
	public int getSort() {
		return sort;
	}

	/**
	 * @param sort
	 *            the sort to set
	 */
	public void setSort(int sort) {
		this.sort = sort;
	}

	/**
	 * @return the parent
	 */
	public Navigation getParent() {
		return parent;
	}

	/**
	 * @param parent
	 *            the parent to set
	 */
	public void setParent(Navigation parent) {
		this.parent = parent;
	}

	/**
	 * @return the children
	 */
	public List<Navigation> getChildren() {
		return children;
	}

	/**
	 * @param children
	 *            the children to set
	 */
	public void setChildren(List<Navigation> children) {
		this.children = children;
	}
}
